import { request } from '@jl/common/utils';
import { IRequestOption } from '@jl/common/composable';

/**
 * 场景列表
 */
export const getSceneList = (
  requestOption: IRequestOption<any, any>
): Promise<API.Base.ResponsePage<API.Scene.SceneListItem>> => {
  return request({
    url: `/api/activity/getActListByMuCond/${requestOption.params.pageSize}/${requestOption.params.index}`,
    method: 'GET',
    ...requestOption,
  });
};

/**
 * 创建场景
 */
export const createScene = (
  requestOption: IRequestOption<any, any>
): Promise<API.Scene.CreateSceneResp> => {
  return request({
    url: `/api/BasOpe/CreateActivity`,
    method: 'POST',
    ...requestOption,
  });
};

/**
 * 编辑场景
 */
export const updateScene = (requestOption: IRequestOption<any, any>): Promise<any> => {
  return request({
    url: `/api/BasOpe/EditActivity`,
    method: 'PUT',
    ...requestOption,
  });
};

/**
 * 复制场景
 */
export const copyScene = (requestOption: IRequestOption<any, any>): Promise<any> => {
  return request({
    url: `/api/activity/copyRecord`,
    method: 'PUT',
    ...requestOption,
  });
};

/**
 * 删除场景
 */
export const deleteScene = (requestOption: IRequestOption<any, any>): Promise<any> => {
  return request({
    url: `/api/activity/delRecord`,
    method: 'DELETE',
    ...requestOption,
  });
};

/**
 * 查询场景详情
 */
export const getSceneDetail = (
  requestOption: IRequestOption<any, API.Scene.GetSceneDetailParams>
): Promise<API.Scene.Scene> => {
  return request({
    url: `/api/BasOpe/GetActDetail`,
    method: 'GET',
    ...requestOption,
  });
};

/**
 * 查询场景详情(免登陆)
 */
export const getSceneDetailNoAuth = (
  requestOption: IRequestOption<any, API.Scene.GetSceneDetailParams>
): Promise<API.Scene.Scene> => {
  return request({
    url: `/api/activity/getActDetail`,
    method: 'GET',
    headers: {
      recordAccess: requestOption.data.recordAccess,
      shareCode: requestOption.data.shareCode,
      resourceCode: requestOption.data.resourceCode,
    },
  });
};

/**
 * 获取在线地图列表
 */
export const getMapList = (): Promise<API.Scene.Map[]> => {
  return request({
    url: '/api/Scene/GetMapList',
    method: 'GET',
  });
};

/**
 * 查询场景版本列表
 */
export const getSceneConfigList = (
  requestOption: IRequestOption<any, API.Scene.GetSceneDetailParams>
): Promise<API.Scene.IVersion[]> => {
  return request({
    url: `/api/BasOpe/GetActConfigList`,
    method: 'GET',
    ...requestOption,
  });
};

// 保存场景
export const saveSceneConfig = (requestOption: IRequestOption<any, any>): Promise<any> => {
  return request({
    url: `/api/BasOpe/SaveActConfig`,
    method: 'POST',
    ...requestOption,
  });
};

// 获取特效列表
export const getEffectList = (
  requestOption: IRequestOption<any, any>
): Promise<API.Scene.IEffectItem[]> => {
  return request({
    url: `/api/effect/getEffsByType`,
    method: 'GET',
    ...requestOption,
  });
};

// 获取特效列表New
export const getEffectListNew = (
  requestOption: IRequestOption<any, any>
): Promise<API.Scene.IEffectItem[]> => {
  return request({
    url: `/api/effect/getEffsByTypeList`,
    method: 'GET',
    ...requestOption,
  });
};

// 创建特效
export const createEffect = (requestOption: IRequestOption<any, any>): Promise<any> => {
  return request({
    url: `/api/effect/createEffect`,
    method: 'POST',
    ...requestOption,
  });
};

// 上传特效图片
export const uploadEffectFile = (requestOption: IRequestOption<any, any>): Promise<any> => {
  return request({
    url: `/api/effect/receiveEffFile`,
    method: 'POST',
    ...requestOption,
  });
};

// 编辑特效
export const editEffect = (requestOption: IRequestOption<any, any>): Promise<any> => {
  return request({
    url: `/api/effect/editEffById`,
    method: 'POST',
    ...requestOption,
  });
};

// 删除特效
export const deleteEffect = (requestOption: IRequestOption<any, any>): Promise<any> => {
  return request({
    url: `/api/effect/delRecord`,
    method: 'DELETE',
    ...requestOption,
  });
};

// 场景分享列表
export const getSceneShareList = (requestOption: IRequestOption<any, any>): Promise<any> => {
  return request({
    url: `/base/admin/shareurlconfig/page`,
    method: 'POST',
    ...requestOption,
  });
};

// 取消分享
export const cancelSceneShare = (requestOption: IRequestOption<any, any>): Promise<any> => {
  return request({
    url: `/base/admin/shareurlconfig/updateStatus`,
    method: 'POST',
    ...requestOption,
  });
};

// 创建分享
export const createSceneShare = (
  requestOption: IRequestOption<API.Scene.ICreateSceneShareParam, any>
): Promise<any> => {
  return request({
    url: `/base/admin/shareurlconfig/add`,
    method: 'POST',
    ...requestOption,
  });
};

// 验证分享链接
export const shareVerifyTicket = (requestOption: IRequestOption<any, any>): Promise<any> => {
  return request({
    url: `/base/api/shareurl/verifyTicket`,
    method: 'GET',
    headers: {
      recordAccess: requestOption.data.recordAccess,
      shareCode: requestOption.data.shareCode,
    },
  });
};

// 分享链接密码验证
export const shareGenTicket = (requestOption: IRequestOption<any, any>): Promise<any> => {
  return request({
    url: `/base/api/shareurl/genTicket`,
    method: 'POST',
    ...requestOption,
  });
};

/**
 * 切换发布状态
 */
export const toggleReleaseState = (requestOption: IRequestOption<any, any>): Promise<any> => {
  return request({
    url: `/api/activity/switchReleState`,
    method: 'PUT',
    ...requestOption,
  });
};

export const verifyResource = (requestOption: IRequestOption<any, any>): Promise<any> => {
  return request({
    url: `/api/resource/verifyResource`,
    method: 'PUT',
    ...requestOption,
  });
};
/**
 * 上传背景图
 * @param requestOption
 * @returns
 */
export const recCommonFile = (requestOption: IRequestOption<any, any>): Promise<any> => {
  return request({
    url: `/api/resource/recCommonFile`,
    method: 'POST',
    ...requestOption,
  });
};

/**
 * 获取背景图
 * @param requestOption
 * @returns
 */
export const getActBkgImgList = (requestOption: IRequestOption<any, any>): Promise<any> => {
  return request({
    url: `/api/activity/getActBkgImgList`,
    method: 'GET',
    ...requestOption,
  });
};

/**
 * 删除背景图
 * @param requestOption
 * @returns
 */
export const delActBkgImg = (requestOption: IRequestOption<any, any>): Promise<any> => {
  return request({
    url: `/api/activity/delActBkgImg`,
    method: 'DELETE',
    ...requestOption,
  });
};

export const getActSkyboxList = (requestOption: IRequestOption<any, any>): Promise<any> => {
  return request({
    url: `/api/activity/getActSkyboxList`,
    method: 'GET',
    ...requestOption,
  });
};

/**
 * 添加场景访问次数
 */
export const insertSceneViewCount = (requestOption: IRequestOption<any, any>): Promise<any> => {
  return request({
    url: '/api/activity/addUsageCount',
    method: 'GET',
    ...requestOption,
  });
};

/**
 * 获取场景LogicMark标志位
 */
export const getActLmState = (requestOption: IRequestOption<any, any>): Promise<any> => {
  return request({
    url: `/api/activity/getActLMState`,
    method: 'PUT',
    ...requestOption,
  });
};

/**
 * 下载离线包
 */
export const downLoadPackage = (data: any): Promise<any> => {
  return request({
    url: `/api/activity/expActResource`,
    method: 'PUT',
    headers: { 'Content-Type': 'multipart/form-data' },
    data,
  });
};

/**
 * 离线包进度
 */
export const getPackageStep = (requestOption: IRequestOption<any, any>): Promise<any> => {
  return request({
    url: `/api/resource/getUploadProg`,
    method: 'GET',
    ...requestOption,
  });
};

/**
 * 获取导出场景资源列表
 */
export const getExpActResoList = (requestOption: IRequestOption<any, any>): Promise<any> => {
  let paramsQuery = {
    blurName: requestOption.blurName,
    projectId: requestOption.projectId,
    appType: 'unknown',
  };
  return request({
    url: `/api/activity/getExpActResoList/${requestOption?.pageSize}/${requestOption?.current}`,
    method: 'GET',
    params: paramsQuery,
  });
};

/**
 * 删除导出场景资源
 */
export const deleteExpActRecord = (requestOption: IRequestOption<any, any>): Promise<any> => {
  return request({
    url: `/api/activity/delExpActRecord`,
    method: 'DELETE',
    ...requestOption,
  });
};
